package com.sg.business.patch01.adminfunction;

import com.mobnut.admin.IFunctionExcutable;
import com.mobnut.commons.util.Utils;
import com.mobnut.db.DBActivator;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.sg.business.model.Document;
import com.sg.business.model.IModelConstants;

public class ImportTestDocument implements IFunctionExcutable {

	public ImportTestDocument() {
	}

	@Override
	public void run() {
		DBCollection docCol = DBActivator.getCollection(IModelConstants.DB, IModelConstants.C_DOCUMENT);
		DBObject doc = docCol.findOne(new BasicDBObject().append(Document.F_DESC,"a"));
		for (int i = 0; i < 100000; i++) {
			doc.removeField("_id");
			doc.put(Document.F_DESC, "a"+i);
			doc.put(Document.F_DOCUMENT_NUMBER, Utils.getRandomString(8, true)+"a0"+i);
			docCol.insert(doc);
			System.out.println(i);
		}
		
		
	}

}
